home *** CD-ROM | disk | FTP | other *** search
- program caller;
-
-
- {This will analyze the CALLERS file produced by RBBS-PC and
- report on several things...
-
- How much time was used on-line
- How many file were uploaded
- downloaded
- aborted
- The files that are downloaded are then listed in
- order of most popular with the number of times.
-
- This ought to keep me busy for a while!! }
-
- const
- userline = 'on at';
- paged = 'Operator paged';
- download = 'Downloaded at';
- upload = '>> uploaded <<';
- violation= 'SV!';
- aborted = 'Aborted at';
- max_recs = 3500;
-
- type
- callertype = array [1..64] of char;
- file_count = record fname : string[12];
- count : integer;
- end;
-
- var
- bigrec : array [1..128] of char;
- inrec,hold : callertype;
- x,y : integer;
- ch : char;
- cfile : file of callertype;
- files : array [1..max_recs] of file_count;
- hour, minute, second : integer;
- col, up, down, page, vio, ab, user : integer;
- fname : string[12];
- placed : boolean;
-
- procedure in_user;
- var st : string[2];
- v,code : integer;
- begin
- user := user + 1;
- hold := inrec;
- seek (cfile, x - 1);
- read (cfile, inrec);
- x := x - 1;
- if inrec[64] = ' ' then
- st := inrec[63]
- else
- st := inrec[63] + inrec[64];
- val (st,v,code);
- second := second + v;
- if second > 59 then begin
- second := second - 59;
- minute := minute + 1;
- if minute > 59 then begin
- minute := minute - 59;
- hour := hour + 1;
- end;
- end;
- if inrec[61] = ' ' then
- st := inrec[60]
- else
- st := inrec[60] + inrec[61];
- val (st,v,code);
- minute := minute + v;
- if minute > 59 then begin
- minute := minute - 59;
- hour := hour + 1;
- end;
- if inrec[58] = ' ' then
- st := inrec[57]
- else
- st := inrec[57] + inrec[58];
- val (st,v,code);
- hour := hour + v;
- end;
-
- procedure in_upload;
- begin
- up := up + 1;
- end;
-
- procedure in_download;
- var x : integer;
- begin
- down := down + 1;
- col := 8;
- fname := '';
- while inrec[col] in ['A'..'Z','.','$','#','!','@','-','0'..'9'] do begin
- fname := fname + inrec[col];
- col := succ(col);
- end;
- x := 1;
- placed := false;
- while not placed do begin
- if fname = files[x].fname then begin
- files[x].count := files[x].count + 1;
- placed := true;
- end
- else
- if files[x].fname = '' then begin
- files[x].fname := fname;
- files[x].count := 1;
- placed := true;
- end;
- x := x + 1;
- end;
- end;
-
- procedure in_aborted;
- begin
- ab := ab + 1;
- end;
-
- procedure in_violation;
- begin
- vio := vio + 1;
- end;
-
- procedure in_paged;
- begin
- page := page + 1;
- end;
-
- procedure init;
- begin
- textcolor (cyan);
- writeln ('Caller Check (c) Copyright John Friel III');
- writeln (' The Forbin Project');
- writeln;
- writeln ('For versions of RBBS-PC CPC12.3A and up.');
- writeln;
- hour := 0; minute := 0; second := 0; up := 0;
- down := 0; page := 0; vio := 0; ab := 0; user := 0;
- for x := 1 to max_recs do
- with files[x] do begin { Zero the counters }
- count := 0;
- fname := '';
- end;
- end;
-
- procedure openfiles;
- begin
- assign (cfile, 'callers');
- reset (cfile);
- x := filesize(cfile); { x hold the total records in the file }
- writeln ('Total Records in the Callers file = ',x);
- writeln;
- writeln ('Working on record');
- end;
-
- procedure scanfile;
- begin
- while x > 0 do begin
- gotoxy (19,8);
- write (x:4);
- seek (cfile, x - 1);
- read (cfile, inrec);
- x := x - 1;
- if pos(userline, inrec) > 0 then
- in_user
- else
- if pos(download, inrec) > 0 then
- in_download
- else
- if pos(upload, inrec) > 0 then
- in_upload
- else
- if pos(aborted, inrec) > 0 then
- in_aborted
- else
- if pos(violation, inrec) > 0 then
- in_violation
- else
- if pos(paged, inrec) > 0 then
- in_paged;
- end;
- writeln (' Done.');
- end;
-
- procedure output_results;
- begin
- writeln;
- write ('Output destination [(S)creen, (P)rinter, (B)oth] ? ');
- repeat
- read (kbd,ch);
- ch := upcase(ch);
- until ch in ['S','P','B'];
- writeln (ch);
- if ch in ['B','S'] then begin
- clrscr;
- writeln ('Statistics are as follows:');
- writeln (' Downloads .... ',down);
- writeln (' Uploads ...... ',up);
- writeln (' Aborts ....... ',ab);
- writeln (' Violations ... ',vio);
- writeln (' Sysop paged .. ',page);
- writeln (' Users ........ ',user);
- writeln (' Time used .... ',hour,':',minute,':',second);
- writeln ;
- writeln (' Files Downloaded : ');
- writeln;
- writeln (' Tap any key to display downloaded files plus times downloaded.');
- read (kbd,ch);
- clrscr;
- writeln;
- writeln (' Files Downloaded : ');
- x := 1;
- while files[x].fname <> '' do begin
- write (' ',files[x].fname:15,'-',files[x].count:3);
- x := succ(x);
- if x/89 = int(x/89) then begin
- writeln;
- write (' Tap any key to continue... ');
- repeat until keypressed;
- read (kbd,ch);
- clrscr;
- writeln (' Files Downloaded : ');
- end;
- end;
- end;
- if ch in ['B','P'] then begin
- writeln (lst,'Statistics are as follows:');
- writeln (lst,' Downloads .... ',down);
- writeln (lst,' Uploads ...... ',up);
- writeln (lst,' Aborts ....... ',ab);
- writeln (lst,' Violations ... ',vio);
- writeln (lst,' Sysop paged .. ',page);
- writeln (lst,' Users ........ ',user);
- writeln (lst,' Time used .... ',hour,':',minute,':',second);
- writeln (lst);
- writeln (lst,' Files Downloaded : ');
- x := 1;
- while files[x].fname <> '' do begin
- write (lst,' ',files[x].fname:15,'-',files[x].count:3);
- x := succ(x);
- end;
- end;
- end;
-
- procedure sort_download_files;
- var
- high : integer;
- done : boolean;
- temp : file_count;
-
- procedure swapit (x : integer);
- begin
- temp := files[x];
- files[x] := files[x+1];
- files[x+1] := temp;
- done := false;
- end;
-
- begin
- writeln;
- write ('Sorting by download frequency and ascending filename.. ');
- high := 0;
- for x := 1 to max_recs do
- if files[x].count <> 0 then high := high + 1;
- { do a quick bubble sort of the data... quick ?!? }
- repeat
- done := true;
- for x := 1 to high-1 do begin
- if files[x].count < files[x+1].count then swapit(x);
- if (files[x].count = files[x+1].count) and
- (files[x].fname > files[x+1].fname) then swapit(x);
- end;
- until done;
- writeln ('Done. '^J^M);
- end;
-
- begin
- init;
- openfiles;
- scanfile;
- sort_download_files;
- output_results;
- end.